package net.lengwang.iot.middleware.packet;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class PacketAnalyzer {
    private static final Logger logger = LoggerFactory.getLogger(PacketAnalyzer.class);
    // parsedPacket

    public String analyzePacketType(ParsedPacket parsedPacket) {
        if (parsedPacket == null || parsedPacket.getCommand() == null) {
            return PacketType.UNKNOWN;
        }

        String command = parsedPacket.getCommand();

        for (String type : PacketType.getAllTypes()) {
            if (command.equals(type)) {
                return type;
            }
        }

        logger.error("未匹配到数据包类型：{}", command);
        return PacketType.UNKNOWN;
    }

}
